package cn.mq.config;

import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

/**
 * RedisMessageListenerContainer配置类
 *
 * @author zhanghui145
 * @date 2022/1/14 10:25
 * @since 1.0.0
 */
@Configuration
public class MqRedisConfiguration {

    @Bean("redisMessageListenerContainer")
    @ConditionalOnMissingBean(RedisMessageListenerContainer.class)
    RedisMessageListenerContainer redisMessageListenerContainer(RedisConnectionFactory redisConnectionFactory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(redisConnectionFactory);
        return container;
    }
}
